package com.hqyj.controller;

import com.hqyj.pojo.Manager;
import com.hqyj.pojo.OutUser;
import com.hqyj.service.OutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/out")
public class OutController {
    @Autowired
    private OutService outService;

    @RequestMapping("getAll")
    public String getAll(ModelMap modelMap) {
        List<OutUser> all = outService.getAll();
        System.out.println(all);
        modelMap.put("OUT", all);
        return "showStrangerList";
    }


    @RequestMapping("/addStranger")
    @ResponseBody
    public Map<String, String> addManager(OutUser outUser) {
        int i = outService.addOutUser(outUser);
        Map<String, String> map = new HashMap<>();
        if (i != 0) {
            map.put("msg", "ok");
        } else {
            map.put("msg", "no");

        }
        return map;
    }

}
